package rs.mbs2.epics.server.session.dao.bean;

import java.util.List;

import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.persistence.Query;

import rs.mbs2.epics.server.entity.Comment;
import rs.mbs2.epics.server.session.dao.localinterface.CommentDaoLocal;


@Stateless
@Local(CommentDaoLocal.class)
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class CommentDaoBean extends GenericDaoBean<Comment, Integer> implements CommentDaoLocal {

	@SuppressWarnings("unchecked")
	@Override
	public List<Comment> findUserComments(Integer userId) {
		Query q = em.createNamedQuery("findUserComments");
		q.setParameter("userId", userId);

		return q.getResultList();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Comment> findPhotoComments(Integer photoId) {
		Query q = em.createNamedQuery("findPhotoComments");
		q.setParameter("photoId", photoId);

		return q.getResultList();
	}
	
}
